package accounts;
import tester.cobertura.Instrument;

/**
 * @author Adam Blackwell
 */
// to represent a premium checking account in a bank.
@Instrument 
public class PremiumChecking extends Checking {

	// Bonus points acumulated from deposits.
	int points;

	/**
	 * @param num
	 * @param name
	 * @param balance
	 * @param owner
	 * @param minimum
	 * @param points
	 */
	public PremiumChecking(int num, String name, int balance, String owner,
			int minimum, int points) {
		super(num, name, balance, owner, minimum);
		this.points = points;
	}

	/*
	 * TEMPLATE: FIELDS: 
	 * ... num ...      -- int
	 * ... name ...     -- String 
	 * ... balance ...  -- int 
	 * ... owner ...    -- String 
	 * ... minimum ...  -- int 
	 * ... points ...   -- int
	 * 
	 * METHODS: 
	 * ... deposit(int amt) ...   -- Account 
	 * ... withdraw(int amt) ...  -- Account
	 */

	// produce an updated account after depositing the given amount
	@Override
	public Account deposit(int amt) {
		return new PremiumChecking(this.num, this.name, this.balance + amt,
				this.owner, this.minimum, this.points + this.points + (amt / 20));
	}

	// produce an updated account after withdrawing the given amount
	@Override
	public Account withdraw(int amt) {
		if (this.balance - this.minimum >= amt) {
			return new PremiumChecking(this.num, this.name, this.balance - amt,
					this.owner, this.minimum, this.points);
		} else {
			throw new RuntimeException(
					"Insufficient Funds in the checking account.");
		}
	}
}